package cn.tedu.start.controller.order;

import cn.tedu.commons.response.JsonResult;

import cn.tedu.pojo.dto.order.OrderTableDTO;


import cn.tedu.pojo.vo.ordervo.OrderStandardVO;
import cn.tedu.service.order.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/order")
public class orderTableController {

    @Autowired
    private IOrderService iOrderAddService;

    @PostMapping("/add")
    public JsonResult addOdrder(@Validated
                               @RequestBody OrderTableDTO orderTebleDTO){
        System.out.println(orderTebleDTO);
        iOrderAddService.addOrder(orderTebleDTO);
        return JsonResult.ok("添加订单完成");

    }

    @GetMapping("/delete")
    public JsonResult deleteOrder(Long id){
        iOrderAddService.deleteOrder(id);
        return JsonResult.ok("删除成功");
    }
    @GetMapping("/update")
    public JsonResult updateOrder(
                                   OrderStandardVO orderVO){
        iOrderAddService.updateOrder(orderVO);
        return JsonResult.ok("修改订单成功");

    }
    @GetMapping("/select")
    public JsonResult selectOrder(String orderId){
        return  iOrderAddService.selectOrder(orderId);
    }
}
